﻿// Reg.cpp : 定义应用程序的入口点。
//

#include "framework.h"
#include "Reg.h"

int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prevInstance, _In_ LPWSTR cmdLine, _In_ int cmdShow)
{
    UNREFERENCED_PARAMETER(instance);
    UNREFERENCED_PARAMETER(prevInstance);
    UNREFERENCED_PARAMETER(cmdLine);
    UNREFERENCED_PARAMETER(cmdShow);
    
    HKEY key;
    RegOpenKeyEx(HKEY_CURRENT_USER, _T("SOFTWARE"), 0, KEY_ALL_ACCESS, &key);
    if (key == NULL)
    {
        MessageBox(NULL, _T("请以管理员身份运行"), _T(""), MB_ICONWARNING);
        return -1;
    }
    RegCreateKeyEx(key, _T("Primal\\Dragon"), 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &key, NULL);

    LPCTSTR value1 = _T("Chinese");
    RegSetValueEx(key, _T("Language"), 0, REG_SZ, (CONST BYTE*)value1, DWORD(_tcslen(value1) * sizeof(TCHAR)));

    RegCreateKeyEx(key, _T("Installation"), 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &key, NULL);
    
    TCHAR path[MAX_PATH];
    GetCurrentDirectory(MAX_PATH, path);
    RegSetValueEx(key, _T("Destination"), 0, REG_SZ, (CONST BYTE*)path, DWORD(_tcslen(path) * sizeof(TCHAR)));

    LPCTSTR value2 = _T("3");
    RegSetValueEx(key, _T("Type"), 0, REG_SZ, (CONST BYTE*)value2, DWORD(_tcslen(value2) * sizeof(TCHAR)));

    RegCloseKey(key);

    RegOpenKeyEx(HKEY_CURRENT_USER, _T("SOFTWARE"), 0, KEY_ALL_ACCESS, &key);
    
    RegCreateKeyEx(key, _T("Wow6432Node\\Primal\\Dragon"), 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &key, NULL);

    RegSetValueEx(key, _T("Language"), 0, REG_SZ, (CONST BYTE*)value1, DWORD(_tcslen(value1) * sizeof(TCHAR)));

    RegCreateKeyEx(key, _T("Installation"), 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &key, NULL);

    RegSetValueEx(key, _T("Destination"), 0, REG_SZ, (CONST BYTE*)path, DWORD(_tcslen(path) * sizeof(TCHAR)));

    RegSetValueEx(key, _T("Type"), 0, REG_SZ, (CONST BYTE*)value2, DWORD(_tcslen(value2) * sizeof(TCHAR)));

    //RegSetValueEx(key, _T("language"), 0, REG_SZ, (CONST BYTE*)value1, _tcslen(value1) * sizeof(TCHAR));

    //_tcscat_s(path, _T("\\everlight.exe"));
    //RegSetValueEx(key, _T("RunCmd"), 0, REG_SZ, (CONST BYTE*)path, _tcslen(path) * sizeof(TCHAR));

    //DWORD value2 = 493;
    //RegSetValueEx(key, _T("DistroID"), 0, REG_DWORD, (CONST BYTE*)&value2, sizeof(DWORD));

    //RegSetValueEx(key, _T("InstallationDirectory"), 0, REG_SZ, (CONST BYTE*)path, _tcslen(path) * sizeof(TCHAR));

    //LPCTSTR value3 = _T("1");
    //RegSetValueEx(key, _T("InstalledGroup"), 0, REG_SZ, (CONST BYTE*)value3, _tcslen(value3) * sizeof(TCHAR));

    //DWORD value4 = 4;
    //RegSetValueEx(key, _T("LangID"), 0, REG_DWORD, (CONST BYTE*)&value4, sizeof(DWORD));

    //LPCTSTR value5 = _T("1");
    //RegSetValueEx(key, _T("Launched"), 0, REG_SZ, (CONST BYTE*)value5, _tcslen(value5) * sizeof(TCHAR));

    //LPCTSTR value6 = _T("77036-133-5335624-40315");
    //RegSetValueEx(key, _T("PID"), 0, REG_SZ, (CONST BYTE*)value6, _tcslen(value6) * sizeof(TCHAR));

    //LPCTSTR value7 = _T("2.2");
    //RegSetValueEx(key, _T("Version"), 0, REG_SZ, (CONST BYTE*)value7, _tcslen(value7) * sizeof(TCHAR));

    //LPCTSTR value8 = _T("RetailVersion");
    //RegSetValueEx(key, _T("VersionType"), 0, REG_SZ, (CONST BYTE*)value8, _tcslen(value8) * sizeof(TCHAR));

    RegCloseKey(key);

    MessageBox(NULL, _T("OK"), _T(""), MB_ICONINFORMATION);
    
    return 0;
}
